from django.shortcuts import HttpResponseRedirect

try:
	from django.utils.deprecation import MiddlewareMixin  # Django 1.10.x
except ImportError:
	MiddlewareMixin = object  # Django 1.4.x - Django 1.9.x


class SimpleMiddleware(MiddlewareMixin):
	def process_request(self, request):

		# 过滤菜谱图片路径
		print(request.path)
		if request.path.startswith('/media/visites/image/cookbook'):
			pass
		else:
			if request.path != '/' and request.path != '/login/loginCheck':
				if request.session.get('session_name', None):
					pass
				else:
					return HttpResponseRedirect('/')


